/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#ifndef __TOOLBOX_H_
#define __TOOLBOX_H_

#include <gccore.h>

#include "control_base.h"
#include "weapon.h"
#include "tool_weapon.h"
#include "map.h"

#define NUM_TOOLS 2

class Toolbox : public ControlBase {
private:
	u32 gold;
	u32 shoes;
	u32 horns;

	int selected_tool;
	const ToolWeapon *tools[NUM_TOOLS];
	
public:
	Toolbox();
	
	static int inside(f32 x, f32 y) {
		return (x >= (MAP_SIZE / 2.0)) && (y >= (-MAP_SIZE / 2.0)) && (y < (MAP_SIZE / 2.0));
	}

	int update(int state, u32 step, WPADData *wiimote_data);
	void draw(int state);
	void text(int state);

	void clear();

	void select_weapon(f32 x, f32 y);

	int legal_position(Map *map, f32 x, f32 y);
	void draw_selected(f32 x, f32 y, int legal);

	int has_selected();
	int can_buy();
	UpgradableWeapon *buy_at(f32 x, f32 y);

	void add_gold(u32 g);
	void add_shoes(u32 g);
	void add_horns(u32 g);
};

#endif
